/*****************************************************************************
 *
 * Copyright (C) 2003 CSHCN, University of Maryland.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Authors: Dionysus Blazakis <dblaze@umd.edu>
 *          Jonathan Polley <jpolley@umd.edu>
 *          Dan Rusk <drusk@umd.edu>
 *          Manish Karir <karir@umd.edu>
 *
 *****************************************************************************/

#ifndef MAODV_GRPH_H
#define MAODV_GRPH_H

#ifndef NS_NO_GLOBALS
#include <endian.h>

#include "defs.h"
#include "multicast_routing_table.h"

/* GRPH Flags: */
#define GRPH_UPDATE   0x2
#define GRPH_OFFMTREE 0x1

typedef struct _grph_t {
    u_int8_t type;
#  if __BYTE_ORDER == __LITTLE_ENDIAN
    u_int8_t res1:6;
    u_int8_t o:1;
    u_int8_t u:1;
#  elif __BYTE_ORDER == __BIG_ENDIAN
    u_int8_t u:1;
    u_int8_t o:1;
    u_int8_t res1:6;
#  else
#   error "Adjust your <bits/endian.h> defines"
#  endif
    u_int8_t res2;
    u_int8_t hcnt;
    u_int32_t grp_leader_addr;
    u_int32_t grp_addr;
    u_int32_t grp_seqno;
} grph_t;

#define GRPH grph_t
#define GRPH_SIZE sizeof(grph_t)

#endif				/* NS_NO_GLOBALS */

#ifndef NS_NO_DECLARATIONS
GRPH *grph_create(u_int8_t flags,
        u_int8_t hcnt,
        u_int32_t grp_leader_addr,
        u_int32_t grp_addr,
        u_int32_t grp_seqno);

void grph_send(u_int8_t flags,
        u_int8_t hcnt,
        u_int32_t grp_addr,
        u_int32_t grp_seqno);

void grph_forward(GRPH * GRPH, int ttl);

void grph_process(GRPH * GRPH, u_int32_t src, int ttl);

void grph_send_callback(mrt_table_t *mrt);

#endif				/* NS_NO_DECLARATIONS */

#endif				/* MAODV_GRPH_H */
